//
//  ShowPersonInforViewController.m
//  lsOA
//
//  Created by 蓝水软件 on 16/7/25.
//  Copyright © 2016年 苏州蓝水有限公司. All rights reserved.
//



//Birthday = "1988-07-24 00:00:00";
//ComID = 1;
//DepID = 19;
//DepName = "\U603b\U7cfb\U7edf\U7ba1\U7406";
//DepartName = "\U62c9\U8428\U5e02\U4ea4\U901a\U4ea7\U4e1a\U96c6\U56e2";
//Email = "";
//HomeAddress = "";
//ID = 1;
//IsLock = 0;
//IsWork = 1;
//JoinTime = "";
//LastLoginIp = "112.25.134.58";
//LastLoginTime = "2016-08-04 15:49:16";
//Notes = "\U7cfb\U7edf\U7ba1\U7406\U5458";
//PassWord = 123456;
//Phone = "";
//Photo = "";
//QQ = "";
//RealName = "\U7ba1\U7406\U5458";
//RegFromIp = "127.0.0.1";
//RegTime = "2016-07-24 15:22:16";
//RoleID = 1;
//Sex = 0;
//Tel = "";
//UserName = manager;
//cName = "\U62c9\U8428\U5e02\U4ea4\U901a\U4ea7\U4e1a\U96c6\U56e2";
//guid = "a9d63f31-5284-48ce-b3d5-86184ccef1ba";

#import "ShowPersonInforViewController.h"
#import "PersonInfoTableViewCell.h"

@interface ShowPersonInforViewController ()<UITableViewDelegate,UITableViewDataSource>{
    UIImageView *headImage;
    UITableView *table;
    NSDictionary *data;
    NSArray *leftArray;
    NSArray *rightArray;
}

@end

@implementation ShowPersonInforViewController
- (void)viewWillAppear:(BOOL)animated{

    self.navigationController.navigationBarHidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated{
    self.navigationController.navigationBarHidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"个人信息";
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    data = [defaults objectForKey:@"underInfoDic"];
    leftArray = @[@"姓名",@"用户名",@"部门",@"职位",@"性别",@"生日",@"手机",@"电话",@"邮件",@"QQ"];
    rightArray = @[@"RealName",@"UserName",@"DepName",@"Notes",@"Sex",@"Birthday",@"Phone",@"Tel",@"Email",@"QQ"];
    [self setUI];
    
    

}

- (void)setUI{
    WS(ws);
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    UIScrollView *scrollView = [[UIScrollView alloc]init];
    scrollView.backgroundColor =  [UIColor colorWithRed:0.396 green:0.365 blue:0.357 alpha:1.000];
    [self.view addSubview:scrollView];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(ws.view).with.insets(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
    scrollView.bounces = NO;
    scrollView.scrollEnabled = YES;
    scrollView.scrollsToTop = NO;
    
    UIView *container = [UIView new];
    [scrollView addSubview:container];
    container.userInteractionEnabled = YES;
    container.backgroundColor = [UIColor colorWithRed:0.396 green:0.365 blue:0.357 alpha:0.8];
    [container mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(scrollView);
        make.edges.equalTo(scrollView).with.insets(UIEdgeInsetsMake(0,0,0,0));
    }];
    
    UIView *ImageUnder = [[UIView alloc]init];
    [container addSubview:ImageUnder];
    ImageUnder.backgroundColor = [UIColor colorWithRed:0.753 green:0.741 blue:0.737 alpha:1.000];
    [ImageUnder mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20);
        make.centerX.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(120*FitSize,120*FitSize));
    }];
    ImageUnder.layer.cornerRadius = 60*FitSize;
    
    headImage = [[UIImageView alloc]init];
    headImage.image = [UIImage imageNamed:@"head"];
    [ImageUnder addSubview:headImage];
    [headImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(ImageUnder);
        make.size.mas_equalTo(CGSizeMake(114*FitSize, 114*FitSize));
    }];
    headImage.layer.cornerRadius = 57*FitSize;
    headImage.layer.masksToBounds = YES;
    
    UILabel *name = [[UILabel alloc]init];
    name.text = [defaults objectForKey:@"UserName"];
    name.textAlignment = NSTextAlignmentCenter;
    name.textColor = [UIColor whiteColor];
    name.font = [UIFont systemFontOfSize:23];
    [container addSubview:name];
    [name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(ImageUnder.mas_bottom).offset(10*FitSize);
        make.centerX.equalTo(container);
        make.width.mas_equalTo(KSWidth);
        make.height.mas_equalTo(25);
    }];
    
    UILabel *companyName = [[UILabel alloc]init];
    companyName.text = [defaults objectForKey:@"cName"];
    companyName.textAlignment = NSTextAlignmentCenter;
    companyName.textColor = [UIColor whiteColor];
    companyName.font = [UIFont systemFontOfSize:15];
    [container addSubview:companyName];
    [companyName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(name.mas_bottom).offset(5*FitSize);
        make.centerX.equalTo(container);
        make.width.mas_equalTo(KSWidth);
        make.height.mas_equalTo(40);
    }];
    table = [[UITableView alloc]init];
    table.delegate = self;
    table.dataSource = self;
    [self.view addSubview:table];
    [table mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(companyName.mas_bottom).offset(30);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [backButton setImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    backButton.frame = CGRectMake(15, 30, 40, 40);
    [backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backButton];
}

- (void)back{
    [self.navigationController popViewControllerAnimated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return leftArray.count;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellID = @"CellID";
    PersonInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
    if (!cell) {
        cell = [[PersonInfoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
    
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    NSString *leftString = leftArray[indexPath.row];
    NSString *rightString = data[rightArray[indexPath.row]];
    [cell setvalueWithleftString:leftString rightString:rightString];
    
    return cell;

}
@end
